const Home = () => import("@/pages/Home");
const Register = () => import("@/pages/Register");
const Login = () => import("@/pages/Login");
const Search = () => import("@/pages/Search");
const Detail =()=>import ("@/pages/Detail");
const AddCartSuccess=()=>import ("@/pages/AddCartSuccess")
const ShopCart=()=>import ("@/pages/ShopCart")
const Trade=()=>import ("@/pages/Trade")
const Pay = () => import("@/pages/Pay")
const PaySuccess = ()=>import("@/pages/PaySuccess")
const Center =()=>import("@/pages/Center")
const MyOrder = ()=>import("@/pages/Center/components/MyOrder")
const TeamOrder = ()=>import("@/pages/Center/components/TeamOrder")
export default [
  {
    path: "/home",
    component: Home,
    name: "home",
  },
  {
    path: "/search/:searchKey?",
    component: Search,
    name: "search",
  },
  {
    path: "/login",
    component: Login,
    name: "login",
    //目前这个meta的值不能通过props传递,然后再App中接受,因为props传递以后,只能在当前路由组件Login中接受
    meta: {
      isHidden: true,
    },
  },
  {
    path: "/register",
    component: Register,
    name: "register",
    meta: {
      isHidden: true,
    },
  },
  {
    path: "/detail/:skuId",
    component: Detail,
    name: "detail",
  },
  {
    path: "/addCartSuccess",
    component: AddCartSuccess,
    name: "addCartSuccess",
  },
  {
    path: "/shopCart",
    component: ShopCart,
    name: "shopCart",
  },
  {
    path: "/trade",
    component: Trade,
    name: "trade",
    beforeEnter: (to, from, next) => {
      if(from.name !="shopCart") return next("/shopCart");
      next();
    }
  },
  {
    path: "/pay",
    component: Pay,
    name: "pay",
    beforeEnter: (to, from, next) => {
      if(from.name !="trade") return next("/trade");
      next();
    }
  },
  {
    path: "/paySuccess",
    component:PaySuccess,
    name: "paySuccess",
    beforeEnter: (to, from, next) => {
      if(from.name !="pay") return next("/pay");
      next();
    }
  },
  {
    path: "/center",
    component: Center,
    // name: "center",
    children:[
      {
        path:"myOrder",
        component:MyOrder,
        name:"myorder",
      },
      {
        path:"teamOrder",
        component:TeamOrder,
        name:"teamOrder",
      },
    ]
  },
  {
    path: "/",
    redirect: "/home",
  },

];
